<!--
 * @Descripttion: 
 * @Author: zhanyi
 * @Date: 2021-10-27 10:07:11
 * @FilePath: \wczd-mobile\src\pages\danger\danger-manager-edit.vue
-->
<template>
  <div class="danger-manager-edit">
    <secondTopPanel>
      <div slot='title'>{{this.formData.dangerState === '0'? '隐患处置' : '查看详情'}}</div>
    </secondTopPanel>
    <div v-if="IsZGForm" class="danger-manager-aaa">
      <div class="select" v-if="formData.isDanger!=='2'">
        <div class="item" :class="{'clicked':this.formData.isDanger==='0'}">隐患确认</div>
        <div class="item" :class="{'clicked':this.formData.isDanger==='1'}">隐患分配</div>
      </div>
      <div class="show">
        <swiper v-if="_swiperData.length!==0" class="swiper" circular indicator-dots autoplay>
          <swiper-item v-for="(item ,index) in _swiperData" :key="index">
            <image v-if="item.type==='image'" mode="aspectFit" class="swiper-item" :src="item.url+'?token='+token" style="width:100%,height:100%">
            </image>
            <video v-if="item.type==='video'" class="swiper-item" :src="item.url+'?token='+token" style="width:100%,height:100%">
            </video>
          </swiper-item>
        </swiper>
        <evanForm v-if="formData!=={}" class="evan-form" :label-style="{width:'180upx',paddingRight:'20upx'}" :model='formData'>
          <evanFormItem label='隐患名称' prop="dangerName">
            {{formData.dangerName}}
          </evanFormItem>
          <evanFormItem label='地点' prop="dangerAddress">
            {{formData.dangerAddress}}
          </evanFormItem>
          <evanFormItem label='创建时间' prop="createTime">
            {{formData.createTime}}
          </evanFormItem>
          <evanFormItem label='来源' prop="dangerSource">
            {{formData.dangerSource==='1'?'隐患排查':formData.dangerSource==='1'?'隐患随手拍':'安全检查'}}
          </evanFormItem>
          <evanFormItem label='隐患类型' prop='dangerType'>
            {{ formData.dangerType }}<span v-if="formData.dangerType2">/{{ formData.dangerType2 }}</span>
          </evanFormItem>
          <evanFormItem label='隐患等级' prop='isBig'>
            <ccPicker class="cc-picker" k="dictLabel" v="dictValue" v-model="formData.isBig" :range="dangerBig"></ccPicker>
          </evanFormItem>
          <evanFormItem label='发现人' prop='findUsername'>
            {{formData.findUsername}}
          </evanFormItem>
          <evanFormItem label='联系电话' prop='contactPhone'>
            {{formData.contactPhone}}
          </evanFormItem>
          <evanFormItem label='具体情况(含建议)' prop="dangerContent">
            {{formData.dangerContent}}
          </evanFormItem>
          <evanFormItem label='照片' prop="dangerUrlsParse" label-position='top'>
            <ImageUpload v-if="formData.dangerUrlsParse" :remove="false" :_max="formData.dangerUrlsParse.length" :imgUrlData='formData.dangerUrlsParse'></ImageUpload>
          </evanFormItem>
          <evanFormItem label='视频' prop="videoUrlsParse" label-position='top'>
            <ImageUpload v-if="formData.videoUrlsParse" :_mediaType="'video'" :remove="false" :_max="formData.videoUrlsParse.length" :imgUrlData='formData.videoUrlsParse'></ImageUpload>
          </evanFormItem>
          <template v-if="formData.isScene==='1'">
            <evanFormItem label='现场整改描述' :label-style="{width:'220upx',paddingRight:'20upx'}">
              {{formData.sceneContent}}
            </evanFormItem>
            <evanFormItem label='现场整改图片' label-position='top' prop='sceneImageUrls' :label-style="{width:'220upx',paddingRight:'20upx'}">
              <ImageUpload @imageUrlCallBack='imageUrlCallBack' :remove="false" :_max="formData.sceneImageUrlsParse.length" :imgUrlData='formData.sceneImageUrlsParse'></ImageUpload>
            </evanFormItem>
            <evanFormItem label='现场整改视频' label-position='top' prop='sceneVideoUrls' :label-style="{width:'220upx',paddingRight:'20upx'}">
              <ImageUpload :_mediaType="'video'" :remove="false" :_max="formData.sceneVideoUrlsParse.length" @imageUrlCallBack='videoUrlCallBack' :imgUrlData='formData.sceneVideoUrlsParse'></ImageUpload>
            </evanFormItem>
          </template>
        </evanForm>
        <div class="ZGForm">
          <evanForm ref="form" v-if="formData!=={}&&formData.isDanger!=='0'" class="evan-form" :label-style="{width:'180upx',paddingRight:'20upx'}" :model='ZGformData' :rules='rules'>
            <evanFormItem label='整改部门' prop="recDeptname" @click="_openDangerDept">
              <input class="form-input" v-model="ZGformData.recDeptname" disabled type="text" placeholder="请选择整改部门">
            </evanFormItem>
            <evanFormItem label='整改人' prop="recUsername" @click="_openDangerUser">
              <input class="form-input" v-model="ZGformData.recUsername" disabled type="text" placeholder="请选择整改人">
            </evanFormItem>
            <evanFormItem label='整改时间' prop="rec_time">
              <uniDatetimePicker type="daterange" v-model="ZGformData.rec_time" :clear-icon='false' :border='false'></uniDatetimePicker>
            </evanFormItem>
          </evanForm>
          <evanForm ref="form2" v-if="formData!=={}&&formData.isDanger!=='0'" class="evan-form" :label-style="{width:'180upx',paddingRight:'20upx'}" :model='YSformData' :rules='rules2'>
            <evanFormItem label='验收部门' prop="checkDeptname" @click="_openCheckDept">
              <input class="form-input" v-model="YSformData.checkDeptname" disabled type="text" placeholder="请选择验收部门">
            </evanFormItem>
            <evanFormItem label='验收人' prop="checkUsername" @click="_openCheckUser">
              <input class="form-input" v-model="YSformData.checkUsername" disabled type="text" placeholder="请选择验收人">
            </evanFormItem>
          </evanForm>
        </div>

        <div class="btn" v-if="formData.isDanger==='0'">
          <button @click="isubmit">非隐患</button>
          <button type="primary" @click="submit">是隐患</button>
          <button v-if="formData.isScene==='1'" type="primary" @click="sceneSubmit">现场整改</button>
        </div>
        <div class="btn2" v-if="formData.isDanger==='1'&&IsZGForm">
          <button type="primary" class="distribution" @click="_distribution">确认分配</button>
        </div>
        <uni-popup ref="dangerDeptPopup">
          <ly-tree @node-click='_dangerDept' :expandOnClickNode='false' :checkOnClickNode="true" :expandOnCheckNode='false' :checkStrictly='true' :accordion='true' :tree-data="dangerDeptTree" node-key="id">
          </ly-tree>
        </uni-popup>
        <uni-popup ref="dangerUserPopup">
          <input class="keyNameInput" type="text" placeholder="请输入姓名查找！" @input="(e)=>keyNameInput(e,'dangerUserPopup')">
          <ly-tree @check='_dangerUser' :props='props' :default-checked-keys='[ZGformData.recUserid]' checkOnClickNode :accordion='true' :showCheckbox='true' :tree-data="dangerUserTree" node-key="userId">
          </ly-tree>
        </uni-popup>
        <uni-popup ref="checkDeptPopup">
          <ly-tree @node-click='_checkDept' :tree-data="checkDeptTree" node-key="id" :expandOnClickNode='false' :checkOnClickNode="true" :expandOnCheckNode='false' :checkStrictly='true' :accordion='true'>
          </ly-tree>
        </uni-popup>
        <uni-popup ref="checkUserPopup">
          <input class="keyNameInput" type="text" placeholder="请输入姓名查找！" @input="(e)=>keyNameInput(e,'checkUserPopup')">
          <ly-tree @check='_checkUser' :tree-data="checkUserTree" node-key="userId" :props='props' :default-checked-keys='[YSformData.checkUserid]' checkOnClickNode :accordion='true' :showCheckbox='true'>
          </ly-tree>
        </uni-popup>
      </div>
    </div>

    <!-- 待整改查看详情 -->
    <div class=" danger-manager-aaa" v-else>
      <div>
        <swiper v-if="_swiperData.length!==0" class="swiper" circular indicator-dots autoplay>
          <swiper-item v-for="(item ,index) in _swiperData" :key="index">
            <image v-if="item.type==='image'" mode="aspectFit" class="swiper-item" :src="item.url+'?token='+token" style="width:100%,height:100%">
            </image>
            <video v-if="item.type==='video'" class="swiper-item" :src="item.url+'?token='+token" style="width:100%,height:100%">
            </video>
          </swiper-item>
        </swiper>
      </div>

      <div class="model-title">一、隐患信息</div>
      <evanForm class="evan-form" :label-style="{width:'180upx',paddingRight:'20upx'}" :model='formData'>
        <evanFormItem label='隐患名称' prop="dangerName">
          {{formData.dangerName}}
        </evanFormItem>
        <evanFormItem label='地点' prop="dangerAddress">
          {{formData.dangerAddress}}
        </evanFormItem>
        <evanFormItem label='来源' prop="dangerAddress">
          {{_setDangerSource(formData)}}
        </evanFormItem>
        <evanFormItem label='隐患状态' prop="dangerName">
          <div class="_right danger-state" :class="_isTextColor(formData)">{{_isDanger(formData)}}</div>
        </evanFormItem>
        <evanFormItem label='创建时间' prop="createTime">
          {{formData.createTime}}
        </evanFormItem>
        <evanFormItem label='隐患类型' prop='dangerType'>
          {{ formData.dangerType }}<span v-if="formData.dangerType2">/{{ formData.dangerType2 }}</span>
        </evanFormItem>
        <evanFormItem label='隐患等级' prop='isBig'>
          <span v-for="(item,index) in dangerBig" :key="'dangerBig'+index">
            <span v-if="item.dictValue===formData.isBig">
              {{ item.dictLabel }}
            </span>
          </span>
        </evanFormItem>
        <evanFormItem label='发现人' prop='findUsername'>
          {{formData.findUsername}}
        </evanFormItem>
        <evanFormItem label='联系电话' prop='contactPhone'>
          {{formData.contactPhone}}
        </evanFormItem>
        <evanFormItem label='具体情况(含建议)' prop="dangerContent">
          {{formData.dangerContent}}
        </evanFormItem>
        <evanFormItem label='照片' prop="recUrlsParse" label-position='top'>
          <ImageUpload v-if="formData.dangerUrlsParse" :remove="false" :_max="formData.dangerUrlsParse.length" :imgUrlData='formData.dangerUrlsParse'></ImageUpload>
        </evanFormItem>
        <evanFormItem label='视频' prop="revVideoUrlsParse" label-position='top'>
          <ImageUpload v-if="formData.videoUrlsParse" :_mediaType="'video'" :remove="false" :_max="formData.videoUrlsParse.length" :imgUrlData='formData.videoUrlsParse'></ImageUpload>
        </evanFormItem>
        <template v-if="formData.isScene==='1'">
          <evanFormItem label='现场整改描述' :label-style="{width:'220upx',paddingRight:'20upx'}">
            {{formData.sceneContent}}
          </evanFormItem>
          <evanFormItem label='现场整改图片' label-position='top' prop='sceneImageUrls' :label-style="{width:'220upx',paddingRight:'20upx'}">
            <ImageUpload @imageUrlCallBack='imageUrlCallBack' :remove="false" :_max="formData.sceneImageUrlsParse.length" :imgUrlData='formData.sceneImageUrlsParse'></ImageUpload>
          </evanFormItem>
          <evanFormItem label='现场整改视频' label-position='top' prop='sceneVideoUrls' :label-style="{width:'220upx',paddingRight:'20upx'}">
            <ImageUpload :_mediaType="'video'" :remove="false" :_max="formData.sceneVideoUrlsParse.length" @imageUrlCallBack='videoUrlCallBack' :imgUrlData='formData.sceneVideoUrlsParse'></ImageUpload>
          </evanFormItem>
        </template>
      </evanForm>
      <div v-if="formData!=={}&&formData.isDanger!=='0'">
        <div class="model-title">二、隐患分配</div>
        <div v-for="(item,index) in ZGFormList" :key="'ZGFormList'+index">
          <evanForm ref="form" class="evan-form" :label-style="{width:'200upx',paddingRight:'20upx'}" :model='item'>
            <evanFormItem label='整改部门' prop="recDeptname">
              <input class="form-input" v-model="item.recDeptname" disabled type="text" placeholder="">
            </evanFormItem>
            <evanFormItem label='整改人' prop="recUsername">
              <input class="form-input" v-model="item.recUsername" disabled type="text" placeholder="">
            </evanFormItem>
            <evanFormItem label='整改开始时间' prop="rec_time">
              <input class="form-input" v-model="item.requireStartTm" disabled type="text" placeholder="">
            </evanFormItem>
            <evanFormItem label='整改结束时间' prop="rec_time">
              <input class="form-input" v-model="item.requireEndTm" disabled type="text" placeholder="">
            </evanFormItem>
            <evanFormItem label='验收部门' prop="checkDeptname">
              <input class="form-input" v-model="item.checkDeptname" disabled type="text" placeholder="">
            </evanFormItem>
            <evanFormItem label='验收人' prop="checkUsername">
              <input class="form-input" v-model="item.checkUsername" disabled type="text" placeholder="">
            </evanFormItem>
          </evanForm>
        </div>
      </div>
      <div class="model-title">三、整改详情</div>
      <div v-if="">
        <evanForm ref="form" class="evan-form" style="padding-top:0;margin-top:10px" :label-style="{width:'180upx',paddingRight:'20upx'}" :model='ZGformData'>
          <evanFormItem label='整改人' prop="recUsername">
            <input class="form-input" v-model="ZGformData.recUsername" disabled type="text" placeholder="">
          </evanFormItem>
          <evanFormItem label='整改反馈内容' prop="recContent">
            <input class="form-input" v-model="ZGformData.recContent" disabled type="text" placeholder="请输入整改反馈内容">
          </evanFormItem>
          <evanFormItem label='照片' prop="recUrls" label-position='top'>
            <ImageUpload v-if="ZGformData.recUrlsParse" :remove="false" :_max="ZGformData.recUrlsParse.length" :imgUrlData='ZGformData.recUrlsParse'></ImageUpload>
          </evanFormItem>
          <evanFormItem label='视频' prop="revVideoUrls" label-position='top'>
            <ImageUpload v-if="ZGformData.revVideoUrlsParse" :remove="false" :_max="ZGformData.revVideoUrlsParse.length" :imgUrlData='ZGformData.revVideoUrlsParse'></ImageUpload>
          </evanFormItem>
        </evanForm>
      </div>
    </div>
  </div>
</template>

<script>
import LyTree from '@/components/ly-tree/ly-tree.vue'
import ImageUpload from "@/pages/component/imageUpload/imageUpload.vue";
import { selectDeptListByMineCompany, selectUserByDeptIds } from "@/api/user";
import secondTopPanel from '@/pages/component/top-panel/secondTopPanel.vue'
import ccPicker from '@/components/cc-picker/cc-picker.vue'
import evanForm from '@/components/evan-form/evan-form.vue'
import evanFormItem from '@/components/evan-form-item/evan-form-item.vue'
import uniDatetimePicker from '@/components/uni-datetime-picker/uni-datetime-picker.vue'
import { confirmDanger, dangerInfoOne, dangerToAllot, rectifyInfoList } from "@/api/danger";
import { getToken } from '@/utils/auth'//获取token

export default {
  name: 'danger-manager-edit',
  components: { secondTopPanel, evanForm, evanFormItem, uniDatetimePicker, LyTree, ImageUpload, ccPicker },
  data () {
    return {
      dangerBig: [],
      recDeptid: null,
      checkDeptid: null,
      IsZGForm: true,
      dangerState: [],
      dangerSource: [],
      rules: {
        recDeptname: [
          { required: true, message: '整改部门不能空' }
        ],
        recUsername: [
          { required: true, message: '整改人不能空' }
        ],
        rec_time: [
          { required: true, message: '整改时间不能空' }
        ],
      },
      rules2: {
        checkDeptname: [
          { required: true, message: '验收部门不能空' }
        ],
        checkUsername: [
          { required: true, message: '验收人不能空' }
        ],
      },
      dangerDeptTree: [],
      dangerUserTree: [],
      checkDeptTree: [],
      checkUserTree: [],
      ZGformData: {
        recUsername: '',
        recUserid: '',
        rec_time: '', // 整改开始-结束时间
        recDeptname: '',
        recDeptid: ''
      },
      ZGFormList: [],
      YSformData: {
        checkUsername: '',
        checkUserid: '',
        check_time: '', // 整改开始-结束时间
        checkDeptname: '',
        checkDeptid: ''
      },
      props: function () {
        return {
          id: 'userId',
          label: 'nickName',
        }
      },
      currentUserKey: [],
      formData: {},
      token: (getToken() ? 'Bearer ' + getToken() : '')
    }
  },
  created () {
    this.getDicts('danger_state').then((response) => {
      this.dangerState = response.data
    })
    this.getDicts('danger_source').then((response) => {
      this.dangerSource = response.data
    })
    this.getDicts('danger_big').then((response) => {
      this.dangerBig = response.data
    })
  },
  computed: {
    // 计算是否是隐患
    _isDanger: function () {
      return function (item) {
        // return item.isDanger === '0' ? '未确定' : item.isDanger === '1' ? (item.dangerState === '1' ? '未指派' : item.dangerState === '2' ? '待整改' : '验收通过') : item.isDanger === '3' ? '现场整改' : '确定非隐患'
        for (let index = 0; index < this.dangerState.length; index++) {
          const element = this.dangerState[index];
          if (element.dictValue === item.dangerState) {
            return element.dictLabel
          }
        }
      }
    },
    // 计算隐患来源
    _setDangerSource: function () {
      return function (item) {
        for (let index = 0; index < this.dangerSource.length; index++) {
          const element = this.dangerSource[index];
          if (element.dictValue === item.dangerSource) {
            return element.dictLabel
          }
        }
      }
    },
    // 计算颜色样式
    _isTextColor: function () {
      return function (item) {
        // return item.isDanger === '0' ? '_RED' : item.isDanger === '1' ? (item.dangerState === '1' ? '_RED' : item.dangerState === '2' ? '_YELLOW' : '_GREEN') : '_RED'
        return item.dangerState === '1' ? '_RED' : item.dangerState === '2' ? '_YELLOW' : item.dangerState === '0' ? '_RED' : '_GREEN'
      }
    },
    // 计算详情图片视频
    _swiperData () {
      let imageData = []
      let videoData = []
      if (this.formData.videoUrlsParse && this.formData.dangerUrlsParse.length !== 0) {
        this.formData.dangerUrlsParse.forEach(element => {
          imageData.push({ 'url': process.uniEnv.baseUrl + '/profile' + element.url, type: 'image' })
        });
      }
      if (this.formData.videoUrlsParse && this.formData.videoUrlsParse.length !== 0) {
        this.formData.videoUrlsParse.forEach(element => {
          videoData.push({ 'url': process.uniEnv.baseUrl + '/profile' + element.url, type: 'video' })
        });
      }
      return [...imageData]
    }
  },
  onLoad: function (option) {
    this._dangerInfoOne(option.dangerId)
    this._getDeptList()
    this._rectifyInfoList(option.dangerId)
    this.IsZGForm = true
  },
  methods: {
    keyNameInput (e, type) {
      if (type === 'dangerUserPopup') {
        this._selectUserByDeptIds(e.detail.value)
      } else {
        this._selectCheckUserByDeptIds(e.detail.value)
      }
    },
    reset () {
      this.formData = {
        id: null,
        dangerSource: '2',
        dangerName: null,
        dangerAddress: null,
        findTime: null,
        dangerType: null,
        dangerType2: null,
        findUsername: null,
        contactPhone: null,
        dangerContent: null,
        dangerUrls: null,
        videoUrls: null,
        dangerState: null,
        dangerUrlsParse: null,
        videoUrlsParse: null,
        sceneImageUrls: null,
        sceneVideoUrls: null,
        sceneImageUrlsParse: null,
        sceneVideoUrlsParse: null,
        downTm: null,
        isScene: null,
        isDanger: null,
        dangerId: null,
        sceneContent: null,
        createTime: null,
        isBig: null,
      }
    },
    // 隐患单条
    _dangerInfoOne (dangerId) {
      this.reset()
      dangerInfoOne({ id: dangerId }).then(res => {
        let item = res.data
        if (res.data) {
          for (let d in this.formData) {
            this.formData[d] = item[d]
          }
          this.formData.dangerUrlsParse = JSON.parse(item.dangerUrls || '[]')
          this.formData.videoUrlsParse = JSON.parse(item.videoUrls || '[]')
          this.formData.sceneImageUrlsParse = JSON.parse(item.sceneImageUrls || '[]')
          this.formData.sceneVideoUrlsParse = JSON.parse(item.sceneVideoUrls || '[]')
        }
      })
    },
    // 获取部门信息
    _getDeptList () {
      selectDeptListByMineCompany({}).then(res => {
        this.dangerDeptTree = res.data
        this.checkDeptTree = res.data
      })
    },
    // 整改信息
    _rectifyInfoList (dangerId) {
      rectifyInfoList({ dangerId: dangerId }).then(res => {
        let foo = res.rows
        if (res.rows.length !== 0) {
          this.IsZGForm = false
          this.ZGFormList = foo

          let item = this.ZGFormList[0]
          item.dangerUrlsParse = []
          item.videoUrlsParse = []
          item.recUrlsParse = []
          item.revVideoUrlsParse = []
          if (item.dangerUrls)
            item.dangerUrlsParse = JSON.parse(item.dangerUrls)
          if (item.videoUrls)
            item.videoUrlsParse = JSON.parse(item.videoUrls)
          if (item.recUrls)
            item.recUrlsParse = JSON.parse(item.recUrls)
          if (item.revVideoUrls)
            item.revVideoUrlsParse = JSON.parse(item.revVideoUrls)
          this.ZGformData = item
        }
      })
    },
    // 打开整改部门
    _openDangerDept () {
      this.$refs.dangerDeptPopup.open('bottom')
    },
    // 打开验收部门
    _openCheckDept () {
      this.$refs.checkDeptPopup.open('bottom')
    },
    // 选中整改部门节点
    _dangerDept (obj) {
      // if (obj.childNodesId.length === 0) {
      this.ZGformData.recDeptname = obj.data.label
      this.ZGformData.recDeptid = obj.data.id
      this.recDeptid = this.ZGformData.recDeptid
      this._selectUserByDeptIds()
      this.$refs.dangerDeptPopup.close()
      // }
    },
    // 选中验收部门节点
    _checkDept (obj) {
      // if (obj.childNodesId.length === 0) {
      this.YSformData.checkDeptname = obj.data.label
      this.YSformData.checkDeptid = obj.data.id
      this.checkDeptid = this.YSformData.checkDeptid
      this._selectCheckUserByDeptIds()
      this.$refs.checkDeptPopup.close()
      // }
    },
    // 根据整改部门id找部门下人员
    _selectUserByDeptIds (name) {
      selectUserByDeptIds({ deptIds: this.recDeptid, nickName: name || '' }).then(res => {
        if (res.rows.length === 0) {
          uni.showToast({
            title: '该部门暂无人员',
            icon: 'none'
          })
          this.ZGformData.recUsername = ''
        } else {
          this.$refs.dangerUserPopup.open('bottom')
        }
        this.dangerUserTree = res.rows
      })
    },
    // 根据验收部门id找部门下人员
    _selectCheckUserByDeptIds (name) {
      selectUserByDeptIds({ deptIds: this.checkDeptid, nickName: name || '' }).then(res => {
        if (res.rows.length === 0) {
          uni.showToast({
            title: '该部门暂无人员',
            icon: 'none'
          })
          this.YSformData.checkUsername = ''
        } else {
          this.$refs.checkUserPopup.open('bottom')
        }
        this.checkUserTree = res.rows
      })
    },
    // 打开整改人
    _openDangerUser () {
      this._selectUserByDeptIds()
      // if (this.dangerUserTree.length === 0) {
      //   uni.showToast({
      //     title: '该部门暂无人员',
      //     icon: 'none'
      //   })
      //   this.ZGformData.recUsername = ''
      // } else {
      //   this.$refs.dangerUserPopup.open('bottom')
      // }
    },
    // 打开验收人
    _openCheckUser () {
      this._selectCheckUserByDeptIds()
      // if (this.checkUserTree.length === 0) {
      //   uni.showToast({
      //     title: '该部门暂无人员',
      //     icon: 'none'
      //   })
      //   this.YSformData.checkUsername = ''
      // } else {
      //   this.$refs.checkUserPopup.open('bottom')
      // }
    },
    // 选中整改人员节点
    _dangerUser (obj) {
      this.ZGformData.recUsername = obj.data.nickName
      this.ZGformData.recUserid = obj.data.userId
      this.$refs.dangerUserPopup.close()
    },
    // 选中验收人员节点
    _checkUser (obj) {
      this.YSformData.checkUsername = obj.data.nickName
      this.YSformData.checkUserid = obj.data.userId
      this.$refs.checkUserPopup.close()
    },
    // 确定隐患
    submit () {
      confirmDanger({ dangerId: this.formData.id, isDanger: '1', isBig: this.formData.isBig }).then(res => {
        uni.showToast({
          title: res.msg,
          icon: 'none'
        })
        this._dangerInfoOne(this.formData.id)
      })
    },
    // 确定非隐患
    isubmit () {
      confirmDanger({ dangerId: this.formData.id, isDanger: '2', isBig: this.formData.isBig }).then(res => {
        uni.showToast({
          title: res.msg,
          icon: 'none'
        })
        this._dangerInfoOne(this.formData.id)
        uni.navigateBack({})
      })
    },
    // 现场整改
    sceneSubmit () {
      confirmDanger({ dangerId: this.formData.id, isDanger: '3', isBig: this.formData.isBig }).then(res => {
        uni.showToast({
          title: res.msg,
          icon: 'none'
        })
        this._dangerInfoOne(this.formData.id)
        uni.navigateBack({})
      })
    },
    // 分配提交
    _distribution () {
      this.$refs.form.validate((response) => {
        if (response) {
          this.$refs.form2.validate((response) => {
            if (response) {
              this.ZGformData.requireStartTm = this.ZGformData.rec_time[0]
              this.ZGformData.requireEndTm = this.ZGformData.rec_time[1]
              this.$set(this.ZGformData, 'dangerId', this.formData.id)
              dangerToAllot({ ...this.ZGformData, ...this.YSformData }).then(res => {
                uni.showToast({
                  title: res.msg,
                  icon: 'none'
                })
                setTimeout(() => {
                  uni.navigateBack()
                }, 500);
              })
            }
          })
        }
      })

    }
  },
}
</script>

<style scoped lang="scss">
.danger-manager-edit {
  height: 100%;
  display: flex;
  flex-direction: column;

  .danger-manager-aaa {
    flex: 1;
    height: 0;
    display: flex;
    flex-direction: column;
    padding-top: 100upx;
  }
}
/deep/ .ly-tree {
  height: 800upx;
  overflow: auto;
  z-index: 9999;
}
.select {
  display: flex;
  justify-content: center;
  align-items: center;
  .item,
  .clicked {
    width: 50%;
    text-align: center;
    line-height: 80upx;
  }
}
.distribution {
  margin-top: 40upx;
  width: 90%;
  line-height: 80upx;
}
.clicked {
  background-color: #00a0e2;
  color: #fff;
}

.evan-form {
  padding: 0 40upx;
  margin-top: 0upx;
  background-color: #fff;
}
.btn {
  margin-top: 40upx;
  margin-bottom: 40upx;
  display: flex;
  justify-content: space-evenly;
  uni-button {
    width: 40%;
    line-height: 34px;
    padding: 0;
    margin: 0;
  }
}
.btn2 {
  padding-bottom: 40upx;
}
.form-input {
  font-size: 28upx;
  color: #333;
  text-align: left;
  width: 100%;
  box-sizing: border-box;
  height: 60upx;
  &.textarea {
    height: 110upx;
    padding: 24rpx 0;
    text-align: left;
  }
}
.img-cont {
  margin: auto;
  display: flex;
  align-items: center;
  .img-item {
    image {
      width: 25vw;
      height: 25vw;
      margin-right: 1vw;
      margin-top: 1vw;
    }
  }
}
.swiper-item {
  width: 100%;
  height: 100%;
}
.swiper {
  height: 200px;
}
.uni-popup {
  width: 100vw;
  height: 100vh;
}
.show {
  flex: 1;
  height: 0;
  overflow-y: scroll;
}
.keyNameInput {
  background-color: #fff;
  padding: 0 80upx;
  height: 50px;
}
/deep/ .uni-popup__wrapper {
  background-color: #fff !important;
  height: 416px;
}
</style>
